import { service } from '@/service'

enum Api {
  list = 'hbsys-system/role/roleSelect',
  addrole = 'hbsys-system/role/addRole',
  roleDetail = 'hbsys-system/role/roleDetail',
  editRole = 'hbsys-system/role/editRole',
  delRole = 'hbsys-system/role/ids',
  exclusionList = 'hbsys-system/role/exclusionList',
  roleAllSelect = 'hbsys-system/role/roleAllSelect',
  exclusionAdd = 'hbsys-system/role/exclusionAdd',
  exclusionDetail = 'hbsys-system/role/exclusionDetail',
  exclusionEdit = 'hbsys-system/role/exclusionEdit',
  exclusionDel = 'hbsys-system/role/exclusion/ids',
  empowerList = 'hbsys-system/role/empowerList',
  changeStatus = 'hbsys-system/role/changeUserStatus',
  empower = 'hbsys-system/role/empowerAdd',
  getAllUserInfo = 'hbsys-system/user/getAllUserInfo',
  empowerDetail = 'hbsys-system/role/empowerDetail',
  empowerDelete = 'hbsys-system/role/empowerDelete',
  resetPwd = 'hbsys-system/role/resetPwd',
  orgPermissions = 'hbsys-system/role/orgPermissions',
  orgPermissionsEdit = 'hbsys-system/role/orgPermissionsEdit',
  roleMenuTreeselect = 'hbsys-system/menu/roleMenuTreeselect',
  menuAdd = 'hbsys-system/menu'
}
export const getLeftList = (params?: any) => {
  return service.request({
    url: Api.list,
    method: 'GET',
    params
  })
}
export const addLeftList = (data: any) => {
  return service.request({
    url: Api.addrole,
    method: 'POST',
    data
  })
}
export const getDetails = (id: number) => {
  return service.request({
    url: Api.roleDetail + '/' + id,
    method: 'GET'
  })
}
export const editRole = (id: number, data: any) => {
  return service.request({
    url: Api.editRole,
    method: 'PUT',
    data
  })
}
export const delRole = (data: any) => {
  return service.request({
    url: Api.delRole,
    method: 'DELETE',
    data
  })
}

// 角色互斥
export const exclusionList = (params?: any) => {
  return service.request({
    url: Api.exclusionList,
    method: 'GET',
    params
  })
}
export const roleAllSelect = (params?: any) => {
  return service.request({
    url: Api.roleAllSelect,
    method: 'GET',
    params
  })
}
export const exclusionAdd = (data: any) => {
  return service.request({
    url: Api.exclusionAdd,
    method: 'POST',
    data
  })
}
export const exclusionDetail = (id: number) => {
  return service.request({
    url: Api.exclusionDetail + '/' + id,
    method: 'GET'
  })
}
export const exclusionEdit = (data: any) => {
  return service.request({
    url: Api.exclusionEdit,
    method: 'PUT',
    data
  })
}
export const exclusionDel = (data: any) => {
  return service.request({
    url: Api.exclusionDel,
    method: 'DELETE',
    data
  })
}

// 账户角色分配
export const empowerList = (params: any) => {
  return service.request({
    url: Api.empowerList,
    method: 'GET',
    params
  })
}
export const changeStatus = (params: any) => {
  return service.request({
    url: Api.changeStatus,
    method: 'PUT',
    params
  })
}
export const empower = (data: any) => {
  return service.request({
    url: Api.empower,
    method: 'POST',
    data
  })
}
export const getAllUserInfo = (params?: any) => {
  return service.request({
    url: Api.getAllUserInfo,
    method: 'GET',
    params
  })
}
export const empowerDetail = (id: any) => {
  return service.request({
    url: Api.empowerDetail + '/' + id,
    method: 'GET'
  })
}
export const empowerDelete = (data: any) => {
  return service.request({
    url: Api.empowerDelete,
    method: 'DELETE',
    data
  })
}
export const resetPwd = (id: any) => {
  return service.request({
    url: Api.resetPwd + '/' + id,
    method: 'PUT'
  })
}

// 组织权限
export const orgPermissions = (params: any) => {
  return service.request({
    url: Api.orgPermissions,
    method: 'GET',
    params
  })
}
export const orgPermissionsEdit = (data: any) => {
  return service.request({
    url: Api.orgPermissionsEdit,
    method: 'PUT',
    data
  })
}
// 功能权限
export const roleMenuTreeselect = (id: any) => {
  return service.request({
    url: Api.roleMenuTreeselect + '/' + id,
    method: 'GET'
  })
}

export const menuAdd = (data: any) => {
  return service.request({
    url: Api.menuAdd,
    method: 'POST',
    data
  })
}
export const menuEdit = (id: number, data: any) => {
  return service.request({
    url: Api.menuAdd,
    method: 'PUT',
    data
  })
}
export const menuDel = (id: number) => {
  return service.request({
    url: Api.menuAdd + '/' + id,
    method: 'DELETE'
  })
}

export const menuDetails = (id: any) => {
  return service.request({
    url: Api.menuAdd + '/' + id,
    method: 'GET'
  })
}

// 角色赋权
export const empowerRole = (data: any) => {
  return service.request({
    url: 'hbsys-system/role',
    method: 'PUT',
    data
  })
}
// 获取角色权限
export const getempowerRoleInfo = (id: any) => {
  return service.request({
    url: 'hbsys-system/role/' + id,
    method: 'get'
  })
}

// 获取角色权限
export const resetPwdUser = (data: any) => {
  return service.request({
    url: 'system/user/resetPwd',
    method: 'put',
    data
  })
}
